<template>
  <!--bread-->
  <div class="bread">
    <ul class="fl sui-breadcrumb">
      <li>
        <a href="#">全部结果</a>
      </li>
    </ul>
    <ul class="fl sui-tag">
      <!-- <li class="with-x">{{searchParams}}</li> -->
      <li class="with-x" v-show="searchParams.categoryName">
        {{ searchParams.categoryName }}<i @click="delClick">×</i>
      </li>
      <li class="with-x" v-show="searchParams.keyword">
        {{ searchParams.keyword }}<i @click="keyClick">×</i>
      </li>
      <li class="with-x" v-show="brand">
        {{ brand }}<i @click="keyClick">×</i>
      </li>
       <!-- <li class="with-x" v-show="wrapList" v-for="(wrap,index) in wrapList" :key="index">
        {{ wrap }}<i @click="keyClick">×</i>
      </li> -->

       <li class="with-x" v-show="propsList" v-for="(props,index) in propsList" :key="index">
        {{ `${props.split(':')[2]}:${props.split(':')[1]}` }}<i @click="propsClick(index)">×</i>
      </li>
 
    </ul>
  </div>
</template>

<script>
export default {
  name: 'Bread',
  props: ['searchParams','brand','wrapList','propsList'],
  data() {
    return {
     
   
    };
  },
  methods: {
    delClick() {
      console.log(111);
      this.$emit('removeCateName');
      console.log(this.$route.query);
      const { keyword } = this.$route.query;
      this.$router.push({
        path: '/search',
        query: {
          keyword,
        },
      });
    },
    
    keyClick() {
      this.$emit('removeKey');
      // console.log(this.$route.query);
      this.$router.push({
        path: '/search',
        query: {
          ...this.$route.query,
          //把路由参数给覆盖
          keyword: undefined,
        },
      }),
        //当点击删除按钮，然后让header组件的input框的值清空
        this.$bus.$emit('removeSearch', this.searchParams.keyword);
    },
    propsClick(index){
        this.$emit('removeProps',index)
    }
  },


};
</script>

<style lang="less" scoped>
.bread {
  margin: 10px 0;
  margin-bottom: 5px;
  overflow: hidden;
  .sui-breadcrumb {
    padding: 3px 15px;
    margin: 0;
    font-weight: 400;
    border-radius: 3px;
    float: left;
    li {
      display: inline-block;
      line-height: 18px;
      a {
        color: #666;
        text-decoration: none;
        &:hover {
          color: #4cb9fc;
        }
      }
    }
  }
  .sui-tag {
    margin-top: -5px;
    list-style: none;
    font-size: 0;
    line-height: 0;
    padding: 5px 0 0;
    margin-bottom: 18px;
    float: left;
    .with-x {
      font-size: 12px;
      margin: 0 5px 5px 0;
      display: inline-block;
      overflow: hidden;
      color: #000;
      background: #f7f7f7;
      padding: 0 7px;
      height: 20px;
      line-height: 20px;
      border: 1px solid #dedede;
      white-space: nowrap;
      transition: color 400ms;
      cursor: pointer;
      i {
        margin-left: 10px;
        cursor: pointer;
        font: 400 14px tahoma;
        display: inline-block;
        height: 100%;
        vertical-align: middle;
      }
      &:hover {
        color: #28a3ef;
      }
    }
  }
}
</style>
